import sequtils, algorithm, math
type
  Category* = enum
    Ones = 1,
    Twos,
    Threes,
    Fours,
    Fives,
    Sixes,
    FullHouse,
    FourOfAKind,
    LittleStraight,
    BigStraight,
    Choice,
    Yacht

proc score*(dices: openArray[int], cat: Category): int =
  let ordered = dices.sorted

  case cat:
  of Ones..Sixes:
    result = dices.count(cat.ord) * cat.ord
  of FullHouse:
    if (ordered[0] == ordered[2] and ordered[3] == ordered[4] or 
      ordered[0] == ordered[1] and ordered[2] == ordered[4]) and 
      ordered[0] != ordered[4]:
      result = ordered.sum   
  of FourOfAKind:
    if ordered[0] == ordered[3]:
      result = ordered[0] * 4
    if ordered[1] == ordered[4]:
      result = ordered[1] * 4      
  of LittleStraight:
    if ordered == [1, 2, 3, 4, 5]:
      result = 30
  of BigStraight:
    if ordered == [2, 3, 4, 5, 6]:
      result = 30
  of Choice:
    result = dices.sum
  of Yacht:
    if ordered[0] == ordered[4]:
      result = 50